package com.gs.common.util

import android.content.Context
import android.widget.Toast

object ToastUtil {

    /**
     * 显示短时间Toast
     * @param context 上下文
     * @param text 显示的内容
     */

    enum class ToastState {
        ON,OFF,TIP,PRODUCT
    }

    private var toastState = ToastState.ON

    fun showShortToast(context: Context, text: String) {
        if (toastState == ToastState.ON) {
            Toast.makeText(context,text, Toast.LENGTH_SHORT).show()
        } else if (toastState == ToastState.TIP){
            Toast.makeText(context, "所有toast已关闭！", Toast.LENGTH_SHORT).show()
            toastState = ToastState.OFF
        } else if (toastState == ToastState.PRODUCT) {
            if (text.contains("登录") || text.contains("注册") || text.contains("服务器") || text.contains("网络")) {
                Toast.makeText(context,text, Toast.LENGTH_SHORT).show()
            }
        }
    }


}